package cn.biplam.front.component.data.tree.nodeList;

import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.Result;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.htmlscript.script.ScriptTree;
import cn.biplam.front.template.control.rfFlowTable.callback.action.ActionCallback;

/**
 *  模型管理索引表树数据平面化后绑定到FlowTable
 * @author XiaoRuxing Nov 25, 20098:44:51 PM
 * @version 1.0
 */
public class MdIndexTreeChildList extends IndexChildList{
	
	/** 节点类型 */
	private String nodeType;
	
	/**
	 * 
	 * @param sHomeUrl      应用系统路径
	 * @param mUser         用户
	 * @param tablePageId   树的targetID
	 * @param recordId      树节点记录ID
	 */
	public MdIndexTreeChildList(
			String sHomeUrl,
			UserInfo mUser,
			String tablePageId,
			String recordId,
			String nodeType){
		super(sHomeUrl, mUser, tablePageId, recordId);
		this.nodeType = nodeType;
	} 
	
	@Override
	protected ActionCallback getDrillAction(String fieldName) {
		TreeRefreshActionCallback callback = new TreeRefreshActionCallback(this.nodeType,
				fieldName);
		return callback;
	}
	
	/**
	 * 数刷新脚本回调器
	 */
	class TreeRefreshActionCallback extends ActionCallback{
		
		private String nodeType;
		
		public TreeRefreshActionCallback(String nodeType,
				String keyField){
			this.nodeType = nodeType;
			this.setCustomerModel();//设置当前为非标准自定义脚本模式
			this.setKeyFieldName(keyField);
		}
		
		@Override
		public String getCustomerScript(Result result, String rowRecordId) throws ErrorMessage {
			return ScriptTree.getTreeRefresh(this.getRecordId(result, rowRecordId), nodeType);
		}

		@Override
		public void process(Result result) {}
	}

	
}
